﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Biza.Core.Orm
{
    public class Transaction : IDisposable
    {
        public Transaction(UnitOfWork uof)
        {
            _uof = uof;
            _uof.BeginTransaction();
        }

        public virtual void Complete()
        {
            _uof.CompleteTransaction();
            _complete = true;
        }

        public void Dispose()
        {
            if (!_complete)
                _uof.AbortTransaction();
        }

        bool _complete;
        UnitOfWork _uof;
    }
}
